import { Controller } from "../../mvc/core/Controller";
import { DataEvent } from "../events/DataEvent";
import { GuideFightingView } from "../view/guide/GuideFightingView";
import { TaskInfo } from "../model/TaskInfo";
import { GuideAutoType } from "../rules/GuideAutoType";
import { ETaskStatus } from "../../../Message/Game/ETaskStatus";
import { GuideType } from "../rules/GuideType";
import { ETaskType } from "../../../Message/Game/ETaskType";
import { EntityType } from "../rules/EntityType";
import { ETaskGroup } from "../../../Message/Game/ETaskGroup";
import { HintIcon } from "../view/uiIconBtn/HintIcon";
import { ImagesConst } from "../resource/ImagesConst";
import { UiHintIconView } from "../view/uiIconBtn/UiHintIconView";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { MapFileUtil } from "../scene/map/MapFileUtil";
import { AIManager } from "../scene/ai/AIManager";
import { AIType } from "../scene/ai/AIType";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { Alert } from "../../../com/mui/controls/Alert";
import { TimerAlertWin } from "../view/common/alertwins/TimerAlertWin";
import { Language } from "../../../extend/language/Language";
import { HTMLUtil } from "../../../com/gengine/utils/HTMLUtil";
import { GameManager } from "../manager/GameManager";
import { ModuleType } from "../view/common/ModuleType";
import { TaskShowConfig } from "../resource/TaskShowConfig";
import { MsgManager } from "../manager/MsgManager";
import { GuideOptType } from "../rules/GuideOptType";
import { ECategory } from "../../../Message/Public/ECategory";
import { EProp } from "../../../Message/Public/EProp";
import { GameController } from "../mvc/GameController";
import { EffectManager } from "../manager/EffectManager";
import { UIIconEvent } from "../view/uiIconBtn/UIIconEvent";
import { PulseSharedObject } from "../view/player/PulseSharedObject";
import { NpcEffectRule } from "../rules/NpcEffectRule";
import { CheckBoxWin } from "../view/common/alertwins/CheckBoxWin";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { RolePlayer } from "../scene/player/entity/RolePlayer";
import { PlayerEvent } from "../scene/events/PlayerEvent";
import { EGateCommand } from "../../../Message/Command/EGateCommand";
import { IView } from "../../mvc/interfaces/IView";
import { STask } from "../../../Message/Game/STask";
import { TaskTargetInfo } from "../model/TaskTargetInfo";
import { GuideTipsManager } from "../manager/GuideTipsManager";
import { ECareer } from "../../../Message/Public/ECareer";
import { AutoFightRule } from "../rules/AutoFightRule";
import { MsgTipInfo } from "../model/MsgTipInfo";
import { ColorConfig } from "../resource/ColorConfig";
import { StatusType } from "../rules/StatusType";
import { GameMapConfig } from "../resource/GameMapConfig";
import { ThingUtil } from "../scene/layer/utils/ThingUtil";
import { MonsterPlayer } from "../scene/player/entity/MonsterPlayer";
import { ActionType } from "../scene/modle/data/ActionType";
import { SWFPlayer } from "../scene/modle/SWFPlayer";
import { LayerManager } from "../manager/LayerManager";
import { StaticResUrl } from "../resource/StaticResUrl";
import { ModelType } from "../scene/modle/data/ModelType";
import { Global } from "../../../com/gengine/global/Global";
import { SPetInfo } from "../../../Message/Game/SPetInfo";
import { ItemsUtil } from "../view/shortcuts/item/ItemsUtil";
import { PetAddWindow } from "../view/pet/PetAddWindow";
import { TaskRule } from "../rules/TaskRule";
import { SPassPoint } from "../../../Message/Public/SPassPoint";
import { BossRefreshInfo } from "../model/BossRefreshInfo";
import { GuideVIPBuyModule } from "../../../modules/GuideVIPBuyModule";
import { GuideBuyFlyModule } from "../../../modules/GuideBuyFlyModule";
import { MessageBlock } from "../../../Framework/MQ/MessageBlock";
import { SPlayerDramaGuide } from "../../../Message/Game/SPlayerDramaGuide";
import { IGuideBuyFlyModule } from "../../../modules/interfaces/IGuideBuyFlyModule";
type int = number;
//class GuideController
    
    export  class GuideController extends Controller
    {
       

        /* internal  */onGuideFightingHandler(arg1: DataEvent): void
        {
            var loc1=0;
            var loc2=0;
            if (cache.guide.isInGuideFightingLevel(cache.role.entityInfo.level)) 
            {
                loc1 = arg1.data["oldValue"] as int;
                loc2 = arg1.data["newValue"] as int;
                this.guideFightingView.show();
                this.guideFightingView.updateValue(loc1, loc2);
            }
            return;
        }

        /* internal  */get guideFightingView(): GuideFightingView
        {
            if (!this._guideFightingView) 
            {
                this._guideFightingView = new GuideFightingView();
            }
            return this._guideFightingView;
        }

        /* internal  */beginGuideTimer(arg1: TaskInfo): void
        {
            if (!arg1 || cache.guide.autoType == GuideAutoType.NoAuto) 
            {
                return;
            }
            var loc1=arg1.getTargetByIndex(0);
            if (!(loc1 == null) && !(loc1.id == cache.guide.delayId)) 
            {
                if (!(arg1.status == ETaskStatus._ETaskStatusCanGet) && arg1.sTask.guide & GuideType.Fly) 
                {
                    this.clearGuideTimer();
                    cache.guide.dalayTarget = loc1;
                    cache.guide.delayType = 1;
                    cache.guide.delayId = loc1.id;
                    if (!(arg1.sTask.type == ETaskType._ETaskTypeCopyStudy && loc1.targetType == EntityType.NPC)) 
                    {
                        this.guideTimer();
                    }
                }
                else if (cache.role.entityInfo.level <= 10 || (arg1.status == ETaskStatus._ETaskStatusHadCompleted || arg1.sTask.type == ETaskType._ETaskTypeEscort) && arg1.sTask.group == ETaskGroup._ETaskGroupMain && (cache.role.entityInfo.level <= 40 || arg1.sTask.guide & GuideType.AutoFight)) 
                {
                    this.clearGuideTimer();
                    cache.guide.dalayTarget = loc1;
                    cache.guide.delayType = 0;
                    cache.guide.delayId = loc1.id;
                    if (!(arg1.sTask.type == ETaskType._ETaskTypeCopyStudy && loc1.targetType == EntityType.NPC)) 
                    {
                        this.guideTimer();
                    }
                }
            }
            return;
        }

        public clearGuideTimer(): void
        {
            this._breaking = false;
            flash.utils.clearTimeout(this._timerKey);
            cache.guide.delayId = 0;
            return;
        }

        public breakGuideTimer(): void
        {
            if (!this._breaking) 
            {
                flash.utils.clearTimeout(this._timerKey);
                this._breaking = true;
            }
            return;
        }

        public continueGuideTimer(): void
        {
            if (this._breaking) 
            {
                this.guideTimer();
                this._breaking = false;
            }
            return;
        }

        /* internal  */showDrameIcon(): void
        {
            if (!this._drameIcon) 
            {
                this._drameIcon = new HintIcon(ImagesConst.DrameHintIcon);
            }
            this._drameIcon.show();
            this._drameIcon.addEventListener(flash.events.MouseEvent.CLICK, this.onDrameIconClickHandler);
            UiHintIconView.instance.addHintIcon(this._drameIcon);
            return;
        }

        /* internal  */guideTimer(): void
        {
            this._breaking = false;
            if (cache.guide.dalayTarget == null) 
            {
                return;
            }
            if (cache.guide.delayType != 1) 
            {
                if (GameMapUtil.isCopyMap(MapFileUtil.mapID)) 
                {
                    return;
                }
                AIManager.onAutoPathAIControl(cache.guide.dalayTarget, AIType.AI_TaskGuide);
                if (cache.role.entityInfo.level < 30) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuideDirBegin, cache.guide.dalayTarget));
                }
            }
            else 
            {
                Alert.mode = Alert.Mode_NoneNotModal;
                Alert.alertWinRenderer = TimerAlertWin;
                Alert.buttonWidth = 100;
                Alert.timerOut = 5;
                Alert.okLabel = Language.getString(20310);
                Alert.show(Language.getStringByParam(20311, HTMLUtil.addColor(Language.getString(20312), "#ff00ff"), HTMLUtil.addColor(cache.guide.dalayTarget.name, "#00ff00")), Language.getString(20055), Alert.OK, null, this.onConveyHandler);
                cache.guide.delayFlyTarget = cache.guide.dalayTarget;
            }
            return;
        }

        /* internal  */onConveyHandler(arg1: int): void
        {
            if (arg1 == Alert.OK && !(cache.guide.dalayTarget == null)) 
            {
                AIManager.cancelAll();
                AIManager.onAIControl(cache.guide.delayFlyTarget, AIType.AI_Convey);
            }
            cache.guide.delayFlyTarget = null;
            return;
        }

        /* internal  */onBeginGame(arg1: DataEvent): void
        {
            var loc1=false;
            if (arg1 != null) 
            {
                loc1 = arg1.data as Boolean;
            }
            var loc2=cache.task.myTaskList[0];
            if (loc2 != null) 
            {
                if (loc1) 
                {
                    this.clearGuideTimer();
                    cache.guide.dalayTarget = loc2.getTargetByIndex(0);
                    cache.guide.delayType = 0;
                    cache.guide.delayId = cache.guide.dalayTarget.id;
                    this.guideTimer();
                }
                else 
                {
                    this.beginGuideTimer(loc2);
                }
            }
            this.guideCheck(cache.task.myTaskList);
            return;
        }

        protected onTaskListRes(arg1: Array<any>): void
        {
            if (cache.role.entityInfo.level != 1) 
            {
                this.onBeginGame(null);
            }
            else 
            {
                GameManager.instance.popupWindow(ModuleType.GuideWelcome);
            }
            return;
        }

        protected onTaskAddRes(arg1: TaskInfo): void
        {
            this.checkTask(arg1, 1);
            return;
        }

        protected onTaskGetRes(arg1: Object): void
        {
            var loc4=null;
            if (arg1 == null || arg1.task == null) 
            {
                return;
            }
            var loc1=arg1.task;
            var loc2=TaskShowConfig.instance.getShowTalkById(loc1.sTask.getTalkId);
            if (loc2) 
            {
                if (loc2.showStr && !(loc2.showStr == "")) 
                {
                    cache.guide.showTaskId = loc1.sTask.code;
                    MsgManager.showTaskTarget(loc2.showStr, loc2.showTime);
                }
                if (loc2.poetry && !(loc2.poetry == "")) 
                {
                    MsgManager.showPlotMsg(loc2.poetry, this.onPlogEndHander);
                    cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                    cache.guide.delayType = 0;
                    cache.guide.delayId = cache.guide.dalayTarget.id;
                    return;
                }
            }
            if (loc1 && loc1.sTask.group == ETaskGroup._ETaskGroupLoopBook) 
            {
                return;
            }
            var loc3=loc1.getTargetByIndex(0);
            if (loc1 && loc1.sTask.type == ETaskType._ETaskTypeTaskCount) 
            {
                if (loc3 && loc3.targetType == GuideOptType.GuideCycleCount) 
                {
                    if ((loc4 = cache.pack.backPackCache.getTypeItems(ECategory._ECategoryProp, EProp._EPropTaskLoopBook)).length > 0) 
                    {
                        GameController.cycle.view.show();
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20241));
                    }
                }
            }
            if (loc1 && loc1.sTask.guide & GuideType.FuBenGuide) 
            {
                this.clearGuideTimer();
                if (this.hasCanGetTask(loc1)) 
                {
                    return;
                }
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                this.guideTimer();
                if (loc1.status == ETaskStatus._ETaskStatusHadCompleted) 
                {
                    cache.guide.copyTaskEndNpc = loc1.getTargetByIndex(0);
                }
                return;
            }
            if (loc1 && loc1.sTask.guide & GuideType.GuideFightSpirit) 
            {
                cache.guide.guideFightSpirit = true;
                GameController.player.view.show();
            }
            if (loc1 && cache.guide.petGuide) 
            {
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                if (!cache.mainUINavbar.isUIByLevel || cache.role.roleInfo.level >= 8) 
                {
                    GameController.pet.view.show();
                }
                return;
            }
            if (loc1 && loc1.sTask.guide & GuideType.GuideNPCEffect) 
            {
                this.clearGuideTimer();
                cache.guide.guideNpcEffect = true;
                if (this.hasCanGetTask(loc1)) 
                {
                    return;
                }
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                this.guideTimer();
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypeRefreshPetGrowth) 
            {
                cache.guide.guidePetRefresh = true;
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Pets));
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypeWeaponStrengthen) 
            {
                cache.guide.guideEquipRefresh = true;
                cache.guide.guideEquipRefreshCount = 0;
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                if (!cache.mainUINavbar.isUIByLevel) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Build));
                }
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypePetMerge) 
            {
                cache.guide.guidePetMerge = true;
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Pets));
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypeLifestyle) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PetLifeStyleGet));
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypeLifestyleDress) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PetLifeStyleDress));
                return;
            }
            if (loc1.sTask.type == ETaskType._ETaskTypePetSite) 
            {
                cache.guide.guidePetSite = true;
            }
            if (loc1 && loc1.sTask.type == ETaskType._ETaskTypeCopyStudy) 
            {
                cache.guide.copyStudy = true;
            }
            if (loc1 && loc1.sTask.type == ETaskType._ETaskTypeGroupKillBoss) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Group));
            }
            if (cache.guide.hasCanGetTask) 
            {
                if (this.hasCanGetTask(loc1)) 
                {
                    return;
                }
                if (cache.guide.endLevelTask) 
                {
                    cache.guide.endLevelTask = false;
                    AIManager.onAutoPathAIControl(loc1.getTargetByIndex(0));
                }
                else if (loc1.sTask.group != ETaskGroup._ETaskGroupSchool) 
                {
                    if (!(loc1.sTask.group == ETaskGroup._ETaskGroupCycle && cache.role.entityInfo.level > 40)) 
                    {
                        this.guideTimer();
                    }
                }
            }
            else 
            {
                if (this.hasCanGetTask(loc1)) 
                {
                    return;
                }
                if (!(loc1.sTask.group == ETaskGroup._ETaskGroupSchool) && !(loc1.sTask.group == ETaskGroup._ETaskGroupGuild) && loc3 && loc3.targetType == EntityType.Boss && cache.role.entityInfo.level >= 10 && cache.role.entityInfo.level <= 40) 
                {
                    cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                    cache.guide.delayType = 0;
                    cache.guide.delayId = cache.guide.dalayTarget.id;
                    this.guideTimer();
                }
                else if (loc1.sTask.group != ETaskGroup._ETaskGroupSchool) 
                {
                    if (loc1.sTask.group != ETaskGroup._ETaskGroupCycle) 
                    {
                        this.beginGuideTimer(loc1);
                    }
                    else if (cache.role.entityInfo.level <= 40) 
                    {
                        cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                        cache.guide.delayType = 0;
                        cache.guide.delayId = cache.guide.dalayTarget.id;
                        this.guideTimer();
                    }
                }
            }
            return;
        }

        /* internal  */onPlogEndHander(): void
        {
            cache.guide.guideShowPlot = false;
            return;
        }

        /* internal  */hasCanGetTask(arg1: TaskInfo): Boolean
        {
            var loc1=null;
            if (!(cache.dialog.npcInfo == null) && cache.task.hasCanGetTask(cache.dialog.npcInfo.tnpc.npcId)) 
            {
                cache.guide.hasCanGetTask = true;
                loc1 = arg1.getTargetByIndex(0);
                if (loc1 != null) 
                {
                    cache.guide.endLevelTask = arg1.endLevel > cache.role.entityInfo.level;
                    cache.guide.dalayTarget = loc1;
                    cache.guide.delayType = 0;
                    cache.guide.delayId = loc1.id;
                }
            }
            else 
            {
                if (cache.guide.hasCanGetTask) 
                {
                    if (cache.guide.dalayTarget && cache.guide.dalayTarget.x == 0 && cache.guide.dalayTarget.y == 0) 
                    {
                        cache.guide.dalayTarget = arg1.getTargetByIndex(0);
                        if (cache.guide.dalayTarget != null) 
                        {
                            cache.guide.endLevelTask = arg1.endLevel > cache.role.entityInfo.level;
                            cache.guide.delayType = 0;
                            cache.guide.delayId = cache.guide.dalayTarget.id;
                        }
                    }
                }
                cache.guide.hasCanGetTask = false;
            }
            return cache.guide.hasCanGetTask;
        }

        protected onCanGetTaskAdd(arg1: Array<any>): void
        {
            var loc2=null;
            if (arg1.length == 0) 
            {
                return;
            }
            var loc1=this.getMainTaskByList(arg1);
            if (!loc1) 
            {
                return;
            }
            if (cache.guide.guideSkillLearn) 
            {
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                return;
            }
            if (cache.guide.guideSkillLearnNot) 
            {
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                this.guideTimer();
                return;
            }
            if (cache.guide.guideUseDrug) 
            {
                cache.guide.dalayTarget = loc1.getTargetByIndex(0);
                cache.guide.delayType = 0;
                cache.guide.delayId = cache.guide.dalayTarget.id;
                return;
            }
            if (cache.guide.guideItemAlert) 
            {
                loc2 = loc1.getTargetByIndex(0);
                if (loc2 != null) 
                {
                    cache.guide.dalayTarget = loc2;
                    cache.guide.delayType = 0;
                    cache.guide.delayId = loc2.id;
                    if (!(loc1.status == ETaskStatus._ETaskStatusCanGet) && loc1.sTask.guide & GuideType.Fly) 
                    {
                        cache.guide.delayType = 1;
                    }
                }
                return;
            }
            if (loc1.sTask.group == ETaskGroup._ETaskGroupLoopBook) 
            {
                return;
            }
            this.beginGuideTimer(loc1);
            return;
        }

        /* internal  */getMainTaskByList(arg1: Array<any>): TaskInfo
        {
            var loc1=0;
            var loc3=null;
            if (arg1.length == 0) 
            {
                return null;
            }
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                if ((loc3 = arg1[loc1]).sTask.group == ETaskGroup._ETaskGroupMain || loc3.sTask.group == ETaskGroup._ETaskGroupChangeCareer) 
                {
                    return loc3;
                }
                ++loc1;
            }
            return arg1[0];
        }

        protected onTaskUpdateRes(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=false;
            var loc2=arg1.length;
            var loc5=true;
            while (loc1 < loc2) 
            {
                if ((loc3 = arg1[loc1]).status != ETaskStatus._ETaskStatusHadCompleted) 
                {
                    this.clearAutoEndTimer(loc3.sTask.code);
                    if (cache.guide.autoType != GuideAutoType.NoAuto) 
                    {
                        if (loc3.sTask.type != ETaskType._ETaskTypeCopyStudy) 
                        {
                            this.beginGuideTimer(loc3);
                        }
                        else if (!loc3.preTargetInfo || !(loc3.preTargetInfo.targetType == EntityType.NPC)) 
                        {
                            this.beginGuideTimer(loc3);
                        }
                    }
                    if (loc3.updateInfo && !(loc3.updateInfo == "")) 
                    {
                        MsgManager.showRollTipsMsg(loc3.updateInfo);
                        MsgManager.addTipText(loc3.updateInfo);
                    }
                }
                else 
                {
                    this.onTaskHadCom(loc3);
                }
                if ((loc4 = this.checkTask(loc3, 2)) == true && loc5 == true) 
                {
                    loc5 = false;
                }
                ++loc1;
            }
            if (loc5 == true) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PathHide));
            }
            return;
        }

        protected onTaskHadCom(arg1: TaskInfo): void
        {
            if (arg1.updateInfo && !(arg1.updateInfo == "")) 
            {
                MsgManager.showRollTipsMsg(arg1.updateInfo);
                MsgManager.addTipText(arg1.updateInfo);
            }
            this.startAutoEndTimer(arg1);
            if (arg1.sTask.group == ETaskGroup._ETaskGroupLoopBook) 
            {
                return;
            }
            if (arg1.sTask.type == ETaskType._ETaskTypeCopyStudy) 
            {
                cache.guide.copyTaskEndNpc = arg1.getTargetByIndex(0);
                cache.guide.copyTowerTaskEnd = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ClickCopyExit));
                cache.guide.copyTaskCom = true;
                if (cache.copy.copyInfo.code == 101) 
                {
                    cache.guide.copyTaskEnd = true;
                    this._stopFightTimeKey = flash.utils.setTimeout(this.stopFightInCopy, 5000);
                }
                return;
            }
            if (cache.guide.fuBenGuide && cache.role.entityInfo.level <= 50 && cache.role.entityInfo.level > 10 && GameMapUtil.isCopyMap(MapFileUtil.mapID) && cache.scene.isCopyNpc(arg1.sTask.endNpc)) 
            {
                cache.guide.copyTaskEndNpc = arg1.getTargetByIndex(0);
                cache.guide.copyTaskCom = true;
                if (cache.copy.copyInfo.code != 101) 
                {
                    if (cache.copy.copyInfo.code == 118 && arg1.sTask.guide & GuideType.FuBenGuide) 
                    {
                        cache.guide.copyTowerTaskEnd = true;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ClickCopyExit));
                    }
                }
                else 
                {
                    cache.guide.copyTaskEnd = true;
                    this._stopFightTimeKey = flash.utils.setTimeout(this.stopFightInCopy, 5000);
                }
                return;
            }
            if (arg1.sTask.guide & GuideType.FuBenGuide) 
            {
                cache.guide.copyTaskEndNpc = arg1.getTargetByIndex(0);
                return;
            }
            if (arg1.sTask.type == ETaskType._ETaskTypePetSite) 
            {
                cache.guide.guidePetSite = false;
            }
            this.hideAutoFightAlert();
            this.beginGuideTimer(arg1);
            return;
        }

        /* internal  */hideDrameIcon(): void
        {
            if (this._drameIcon && this._drameIcon.parent) 
            {
                this._drameIcon.parent.removeChild(this._drameIcon);
                EffectManager.glowFilterUnReg(this._drameIcon);
                this._drameIcon.dispatchEvent(new UIIconEvent(UIIconEvent.RemoveIcon));
            }
            return;
        }

        /* internal  */onDrameIconClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hideDrameIcon();
            Alert.showCloseBtn = true;
            Alert.okLabel = Language.getString(27521);
            Alert.calcelLabel = Language.getString(27522);
            Alert.show(Language.getString(26520), Language.getString(20055), Alert.OK | Alert.CANCEL, null, this.onDrameAlertClose);
            return;
        }

        /* internal  */onDrameAlertClose(arg1: int): void
        {
            var loc1=cache.task.getDrameTask();
            if (loc1) 
            {
                if (arg1 != Alert.OK) 
                {
                    if (arg1 == Alert.CANCEL) 
                    {
                        AIManager.onAIControl(loc1.getTargetByIndex(0), AIType.AI_Convey);
                    }
                }
                else 
                {
                    AIManager.onAutoPathAIControl(loc1.getTargetByIndex(0));
                }
                if (cache.guide.guideDramaInfo.dramaGuide == 0) 
                {
                    this.showDrameIcon();
                }
            }
            return;
        }

        /* internal  */startAutoEndTimer(arg1: TaskInfo): void
        {
            if (cache.role.entityInfo.level <= 20) 
            {
                if (PulseSharedObject.isTodayNotTips(cache.guide.guideAutoEndAlert)) 
                {
                    return;
                }
                this.clearAutoEndTimer();
                this._autoEndTask = arg1;
                this._autoEndTimer = flash.utils.setTimeout(this.onAutoEndTimer, cache.guide.guideAutoEndTime, arg1);
            }
            return;
        }

        /* internal  */onAutoEndTimer(arg1: TaskInfo): void
        {
            var loc1=null;
            if (arg1) 
            {
                loc1 = arg1.getTargetByIndex(0);
                if (loc1) 
                {
                    if ((!AIManager.lastTarget || !AIManager.checkLastTargetAsNPC(loc1.id)) && !NpcEffectRule.hasDialogByNpcId(loc1.id)) 
                    {
                        if (!(this._autoEndAlert && this._autoEndAlert.parent)) 
                        {
                            Alert.alertWinRenderer = CheckBoxWin;
                            Alert.buttonWidth = 100;
                            Alert.okLabel = Language.getString(21111);
                            Alert.buttonStyleName = "DialogOptBtn2";
                            Alert.showCloseBtn = true;
                            Alert.extendObj = this._autoEndTask;
                            this._autoEndAlert = Alert.show(Language.getStringByParam(21110, HTMLUtil.addColor(arg1.taskName, "#00ff00")), Language.getString(20055), Alert.OK, null, this.onAutoEndAlert);
                        }
                    }
                }
            }
            return;
        }

        /* internal  */onAutoEndAlert(arg1: int, arg2: TaskInfo, arg3: Boolean, arg4: Boolean=false): void
        {
            this._autoEndAlert = null;
            if (arg1 == Alert.OK && !arg4) 
            {
                if (arg2) 
                {
                    AIManager.onAutoPathAIControl(arg2.getTargetByIndex(0), AIType.AI_TaskGuide);
                }
            }
            if (arg3) 
            {
                PulseSharedObject.save(cache.guide.guideAutoEndAlert, true);
                this.clearAutoEndTimer();
            }
            else if (arg2) 
            {
                this.startAutoEndTimer(arg2);
            }
            return;
        }

        public clearAutoEndTimer(arg1: int=0): void
        {
            if (arg1 == 0 || this._autoEndTask && this._autoEndTask.sTask.code == arg1) 
            {
                flash.utils.clearTimeout(this._autoEndTimer);
                this._autoEndTask = null;
            }
            return;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            NetDispatcher.addCmdListener(ServerCommand.TaskListRes, this.onTaskListRes);
            NetDispatcher.addCmdListener(ServerCommand.TaskAdd, this.onTaskAddRes);
            NetDispatcher.addCmdListener(ServerCommand.TaskGetRes, this.onTaskGetRes);
            NetDispatcher.addCmdListener(ServerCommand.TaskUpdate, this.onTaskUpdateRes);
            NetDispatcher.addCmdListener(ServerCommand.TaskCancelRes, this.onTaskCancelRes);
            NetDispatcher.addCmdListener(ServerCommand.CanGetListAdd, this.onCanGetTaskAdd);
            NetDispatcher.addCmdListener(ServerCommand.CanGetListRefresh, this.onCanGetTaskAdd);
            NetDispatcher.addCmdListener(ServerCommand.TaskEndRes, this.onTaskEndRes);
            Dispatcher.addEventListener(EventName.Guide_BeginGame, this.onBeginGame);
            Dispatcher.addEventListener(EventName.Convey_Res, this.onConveyRes);
            Dispatcher.addEventListener(EventName.AI_NpcOutDestance, this.onOutNpcDistance);
            Dispatcher.addEventListener(EventName.Guide_UpdateCareer, this.onUpdateCareer);
            Dispatcher.addEventListener(EventName.Scene_Update, this.onSceneUpdateHandler);
            Dispatcher.addEventListener(EventName.Guide_ItemUsed, this.onGuideItemUsed);
            Dispatcher.addEventListener(EventName.Guide_FirstAttackHide, this.onFirstAttackHide);
            Dispatcher.addEventListener(EventName.PetBattleSuccess, this.onPetBattleSuccessHandler);
            Dispatcher.addEventListener(EventName.PetBattle, this.onPetBattleHandler);
            Dispatcher.addEventListener(EventName.ShopClose, this.onShopCloseHandler);
            Dispatcher.addEventListener(EventName.WareClose, this.onWareCloseHandler);
            Dispatcher.addEventListener(EventName.SkillWindowClose, this.onSkillWindowCloseHandler);
            Dispatcher.addEventListener(EventName.PetWindowClose, this.onPetWindowCloseHandler);
            Dispatcher.addEventListener(EventName.Equipment_WindowClose, this.onEquipmentWindowCloseHandler);
            Dispatcher.addEventListener(EventName.GuildListWindowClose, this.onGuildListWindowClose);
            Dispatcher.addEventListener(EventName.PackWindowClose, this.onPackWindowCloseHandler);
            Dispatcher.addEventListener(EventName.AI_FightInDistance, this.onAIFightInDisHandler);
            Dispatcher.addEventListener(EventName.BeginToFight, this.onAutoFightBeginHandler);
            Dispatcher.addEventListener(EventName.BeginToFightShortcut, this.onAutoFightBeginHandler);
            Dispatcher.addEventListener(EventName.OverFight, this.onAutoFightEndHandler);
            RolePlayer.instance.addEventListener(PlayerEvent.PLAYER_FIRE, this.onPlayerFireHandler);
            NetDispatcher.addCmdListener(ServerCommand.Copy_ProcessUpdate, this.onCopyProcessUpdate);
            RolePlayer.instance.addEventListener(PlayerEvent.GIRD_WALK_END, this.onGridWorkEnd);
            Dispatcher.addEventListener(EventName.CopyCopyReset, this.onCopyResetHandler);
            Dispatcher.addEventListener(EventName.Guide_VIPTestEnd, this.onVipTestEnd);
            Dispatcher.addEventListener(EventName.Guide_FlyFootBuy, this.onFlyFootBuy);
            RolePlayer.instance.addEventListener(PlayerEvent.Enter_Fight, this.onEnterFightHandler);
            Dispatcher.addEventListener(EventName.PetAddWindowClose, this.onPetAddWindowCloseHandler);
            Dispatcher.addEventListener(EventName.PetAddWindowShow, this.onPetAddWindowShowHandler);
            Dispatcher.addEventListener(EventName.AIFightPointMoveEnd, this.onFightPointMoveEndHandler);
            RolePlayer.instance.addEventListener(PlayerEvent.RoleLevelUpdate, this.onRoleLevelUpDateHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGatePlayerDramaGuide, this.onPlayerDrameGuideRes);
            Dispatcher.addEventListener(EventName.Guide_Fighting, this.onGuideFightingHandler);
            return;
        }

        protected /* override */ initView(): IView
        {
            return super.initView();
        }

        /* internal  */stopFightInCopy(): void
        {
            MsgManager.showCopyEndStr(Language.getString(20313), 1, 30, this.onCopyEndTimeCom);
            Alert.alertWinRenderer = TimerAlertWin;
            Alert.buttonWidth = 100;
            Alert.timerOut = 30;
            Alert.okLabel = Language.getString(20314);
            Alert.calcelLabel = Language.getString(20315);
            this._stopFightAlert = Alert.show(Language.getString(20316) + "<br>" + HTMLUtil.addColor("（" + Language.getString(20317) + "）", "#00ff00"), Language.getString(20055), Alert.OK | Alert.CANCEL, null, this.onExitAlertHandler);
            return;
        }

        /* internal  */onExitAlertHandler(arg1: int): void
        {
            if (arg1 != Alert.OK) 
            {
                MsgManager.hideCopyEndStr();
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CopyLeaveWithoutComfirm));
            }
            return;
        }

        /* internal  */onCopyEndTimeCom(): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyLeaveWithoutComfirm));
            return;
        }

        protected onTaskCancelRes(arg1: STask): void
        {
            this.clearAutoEndTimer(arg1.code);
            if (arg1.guide != 0) 
            {
                this.guideCheck(cache.task.myTaskList);
            }
            return;
        }

        protected onTaskEndRes(arg1: Object): void
        {
            if (arg1 == null || arg1.task == null) 
            {
                return;
            }
            var loc1=arg1.task;
            this.clearAutoEndTimer(loc1.sTask.code);
            if (loc1.sTask.code == cache.guide.showTaskId) 
            {
                cache.guide.showTaskId = 0;
                MsgManager.removeTaskTarget();
            }
            if (loc1.sTask.guide & GuideType.GuideSkillLearn) 
            {
                cache.skill.updateLearnAble();
                if (cache.skill.skillLearnAble.length > 0) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_SkillLearn));
                    return;
                }
                cache.guide.guideSkillLearn = false;
                cache.guide.guideSkillLearnNot = true;
            }
            else if (loc1.sTask.guide & GuideType.GuideYuyan2) 
            {
                cache.guide.guideCopyStory = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_CopyStoryGuide, true));
            }
            if (loc1.sTask.type == ETaskType._ETaskTypeLifestyleDress) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PetLifeDressOptEnd));
            }
            this.checkTask(loc1, 3);
            return;
        }

        protected onConveyRes(arg1: DataEvent): void
        {
            cache.guide.delayFlyTarget = null;
            var loc1=arg1.data as TaskTargetInfo;
            if (loc1 == null) 
            {
                return;
            }
            if (GuideTipsManager.target == null) 
            {
                return;
            }
            if (loc1 == GuideTipsManager.target) 
            {
                GuideTipsManager.hideGuideTips();
            }
            return;
        }

        /* internal  */onOutNpcDistance(arg1: DataEvent): void
        {
            this.guideCheck(cache.task.myTaskList);
            return;
        }

        /* internal  */onUpdateCareer(arg1: DataEvent): void
        {
            this.guideCheck(cache.task.myTaskList);
            return;
        }

        /* internal  */guideCheck(arg1: Array<any>): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=false;
            var loc1=0;
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                if (loc5 = this.checkTask(loc3)) 
                {
                    break;
                }
                ++loc1;
            }
            if (!loc5) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PathHide));
            }
            return;
        }

        /* internal  */checkTask(arg1: TaskInfo, arg2: int=0): Boolean
        {
            var loc1=false;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            cache.guide.npcBuyTask = null;
            cache.guide.npcRepairTask = null;
            if (!arg1 || !arg1.sTask) 
            {
                return false;
            }
            var loc2;
            if (!(loc2 = arg1.getTargetByIndex(0))) 
            {
                return false;
            }
            if (cache.role.entityInfo.level <= 20 && arg2 == 0 && arg1.status == ETaskStatus._ETaskStatusHadCompleted) 
            {
                this.startAutoEndTimer(arg1);
            }
            if (arg1.sTask.guide & GuideType.FuBenGuide && arg2 == 1) 
            {
                cache.guide.fuBenGuide = true;
                cache.guide.copyTaskCom = false;
                loc1 = true;
            }
            else if (arg1.sTask.guide & GuideType.GuideTips) 
            {
                if (loc2.targetType != EntityType.Boss) 
                {
                    if (loc2.targetType != EntityType.NPC) 
                    {
                        if (arg1.sTask.group == ETaskGroup._ETaskGroupTransport) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_NPCFind, arg1));
                        }
                    }
                    else 
                    {
                        if (!(!(cache.dialog.npcInfo == null) && cache.dialog.npcInfo.tnpc.npcId == loc2.id && !GameController.dialog.view.isHide)) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_NPCFind, arg1));
                        }
                        loc1 = true;
                    }
                }
                else 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_BossFind, arg1));
                    loc1 = true;
                }
            }
            else if (arg1.sTask.guide & GuideType.Fly) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_Fly, arg1));
                loc1 = true;
            }
            if (arg1.sTask.guide & GuideType.UpdateCareer) 
            {
                if (cache.guide.selectedCareer) 
                {
                    AIManager.onAutoPathAIControl(loc2);
                }
                else if (cache.role.entityInfo.career == ECareer._ECareerNewPlayer) 
                {
                    GameController.career.view.show();
                }
                loc1 = true;
            }
            else if (arg1.sTask.guide & GuideType.AutoFight && arg2 == 1) 
            {
                if (!AutoFightRule.isAutoFight()) 
                {
                    cache.guide.autoFightGuide = true;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_Hang));
                    loc1 = true;
                }
            }
            else if (arg1.sTask.guide & GuideType.LifeBar && arg2 == 1) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_LifeBar));
                loc1 = true;
            }
            else 
            {
                if (arg1.sTask.type == ETaskType._ETaskTypeMallBuy && arg1.isNpcShopGuide() && arg2 == 1) 
                {
                    cache.guide.npcBuyTask = arg1;
                    if (cache.dialog.npcInfo && cache.guide.npcBuyTask) 
                    {
                        if ((loc3 = cache.dialog.operateList[0]) != null) 
                        {
                            GameManager.instance.popupWindow(loc3.operateId);
                        }
                    }
                    return true;
                }
                if (arg1.sTask.type == ETaskType._ETaskTypeRepair && arg2 == 1) 
                {
                    cache.guide.npcRepairTask = arg1;
                    if (cache.dialog.npcInfo && cache.guide.npcRepairTask) 
                    {
                        if ((loc4 = cache.dialog.operateList[0]) != null) 
                        {
                            GameManager.instance.popupWindow(loc4.operateId);
                        }
                    }
                    return true;
                }
                if (arg1.sTask.guide & GuideType.GiftPackUse && arg2 == 3) 
                {
                    if ((loc5 = cache.pack.backPackCache.getTypeLevelItems(ECategory._ECategoryProp, EProp._EPropFixGiftBag, 10)).length > 0) 
                    {
                        loc6 = loc5[0];
                        (loc7 = new MsgTipInfo()).contentArr.push(Language.getStringByParam(20318, loc6.itemInfo.item.name));
                        loc7.colorArr.push(16777215);
                        loc7.itemDataArr.push(loc6);
                        loc7.itemColorArr.push(ColorConfig.instance.getItemColor(loc6.itemInfo.item.color).color);
                        loc7.isClick = 1;
                        loc7.isAutoHide = true;
                        loc7.clickEventArr.push(EventName.ShowBackPackModule);
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipDateChange, loc7));
                        return true;
                    }
                }
                else 
                {
                    if (arg1.sTask.guide & GuideType.DailyModule && arg2 == 3) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.GuideDailyModule));
                        return true;
                    }
                    if (arg1.sTask.type == ETaskType._ETaskTypeApplyGuild && cache.guild.myGuildInfo == null && (arg2 == 1 || arg2 == 0 && arg1.status == ETaskStatus._ETaskStatusNotCompleted)) 
                    {
                        cache.guide.guideApplyGuild = true;
                        loc1 = true;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ApplyGuild, arg1));
                        if (!cache.mainUINavbar.isUIByLevel) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Guild));
                        }
                    }
                    else if (arg1.sTask.type == ETaskType._ETaskTypeRefreshPetGrowth && arg2 == 1 && !cache.guide.guidePetRefresh && !cache.guide.guidePetRefreshEd) 
                    {
                        cache.guide.guidePetRefresh = true;
                        cache.guide.dalayTarget = arg1.getTargetByIndex(0);
                        cache.guide.delayType = 0;
                        cache.guide.delayId = cache.guide.dalayTarget.id;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Pets));
                        loc1 = true;
                    }
                    else if (arg1.sTask.type == ETaskType._ETaskTypeWeaponStrengthen && arg2 == 1 && !cache.guide.guideEquipRefresh && (!(cache.pack.backPackCache.getTypeItems(ECategory._ECategoryEquip).length == 0) || !(cache.pack.rolePackCache.getTypeItems(ECategory._ECategoryEquip).length == 0))) 
                    {
                        cache.guide.guideEquipRefresh = true;
                        cache.guide.dalayTarget = arg1.getTargetByIndex(0);
                        cache.guide.delayType = 0;
                        cache.guide.delayId = cache.guide.dalayTarget.id;
                        if (!cache.mainUINavbar.isUIByLevel) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Build));
                        }
                        loc1 = true;
                    }
                    else if (arg1.sTask.type == ETaskType._ETaskTypePetMerge && arg2 == 1 && !cache.guide.guidePetMerge) 
                    {
                        cache.guide.guidePetMerge = true;
                        cache.guide.dalayTarget = arg1.getTargetByIndex(0);
                        cache.guide.delayType = 0;
                        cache.guide.delayId = cache.guide.dalayTarget.id;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.Pets));
                        loc1 = true;
                    }
                    else if (arg1.sTask.type == ETaskType._ETaskTypePetSite && (arg2 == 0 || arg2 == 1) && arg1.status == ETaskStatus._ETaskStatusNotCompleted && !cache.guide.guidePetSite) 
                    {
                        cache.guide.guidePetSite = true;
                    }
                    else if (arg1.sTask.type == ETaskType._ETaskTypeLifestyle && arg2 == 0 && arg1.status == ETaskStatus._ETaskStatusNotCompleted) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PetLifeStyleGet));
                    }
                    else if (arg1.sTask.guide & GuideType.GuideCollection && (arg2 == 1 || arg2 == 0)) 
                    {
                        if (arg2 == 1) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_VIPFly, arg1));
                        }
                        loc1 = true;
                    }
                }
            }
            if (arg1.endLevel > cache.role.entityInfo.level && arg2 == 1) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_DailyAct, arg1));
                loc1 = true;
            }
            if (arg1.sTask.guide & GuideType.GuideDaily && (arg2 == 1 || arg2 == 0)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_CanonBookShow));
                loc1 = true;
            }
            return loc1;
        }

        /* internal  */onAutoFightAlertHandler(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                if (!AutoFightRule.isAutoFight()) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightKeyToFight));
                }
            }
            this._autoFightAlert = null;
            return;
        }

        /* internal  */onEscortIsAttacked(arg1: DataEvent): void
        {
            if (cache.status.currentStatus == StatusType.AutoPath) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoPathEnd));
            }
            AIManager.cancelAll();
            RolePlayer.instance.stopWalking();
            return;
        }

        /* internal  */onSceneUpdateHandler(arg1: DataEvent): void
        {
            var loc2=null;
            var loc3=null;
            if (cache.role.entityInfo.level <= cache.guide.doubleClickLevel) 
            {
                cache.guide.doubleClick = true;
            }
            flash.utils.clearTimeout(this._stopFightTimeKey);
            if (this._stopFightAlert && this._stopFightAlert.parent) 
            {
                this._stopFightAlert.parent.removeChild(this._stopFightAlert);
                this._stopFightAlert = null;
            }
            var loc1=GameMapConfig.instance.getMapInfo(MapFileUtil.mapID);
            if (!(loc1 == null) && !(loc1.des == null) && !(loc1.des == "")) 
            {
                MsgManager.showSceneDes(loc1.name, loc1.desArray);
            }
            else 
            {
                MsgManager.hideSceneDes();
            }
            if (GameMapUtil.isCopyMap(MapFileUtil.mapID)) 
            {
                if (cache.role.entityInfo.level < 45 && cache.guide.isAutoFightCopy()) 
                {
                    if (!AutoFightRule.isAutoFight()) 
                    {
                        cache.guide.autoFightGuide = true;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.AutoFight));
                    }
                }
                if (cache.guide.copyStudy) 
                {
                    if (cache.guide.dalayTarget && cache.guide.dalayTarget.mapId == MapFileUtil.mapID) 
                    {
                        AIManager.onAutoPathAIControl(cache.guide.dalayTarget);
                    }
                }
                else if (cache.guide.fuBenGuide) 
                {
                    if (cache.copy.copyInfo.code != 101) 
                    {
                        if (cache.copy.copyInfo.code == 105) 
                        {
                            AIManager.onAutoPathAIControl(cache.guide.copyTaskEndNpc);
                        }
                    }
                    else 
                    {
                        Alert.okLabel = Language.getString(20319);
                        Alert.buttonWidth = 100;
                        Alert.show(Language.getStringByParam(20320, HTMLUtil.addColor(cache.copy.copyInfo.name, "#00ff00"), HTMLUtil.addColor(Language.getString(20319), "#ff00ff")), Language.getString(20055), Alert.OK, null, this.onCopyAutoFightAlertHandler);
                    }
                    if (!cache.copy.isInMagicTower() || cache.copy.magicTowerInfo.floor == 1) 
                    {
                        flash.utils.setTimeout(this.onEnterCopyGuide, 2000);
                    }
                }
            }
            else if (cache.guide.fuBenGuide) 
            {
                cache.guide.fuBenGuide = false;
                if (cache.guide.copyTaskEnd) 
                {
                    cache.guide.copyTaskEnd = false;
                    MsgManager.hideCopyEndStr();
                    cache.guide.guideCopyLuckDraw = true;
                }
                if (cache.guide.copyTaskEndNpc) 
                {
                    AIManager.onAutoPathAIControl(cache.guide.copyTaskEndNpc);
                }
                if (cache.guide.guideTargetPoint) 
                {
                    cache.guide.guideTargetEntity = null;
                    cache.guide.guideTargetPoint = false;
                    RolePlayer.instance.removeTargetTilePoint();
                }
                if (cache.guide.copyTowerTaskEnd) 
                {
                    cache.guide.copyTowerTaskEnd = false;
                }
            }
            else if (cache.guide.copyStudy) 
            {
                cache.guide.copyStudy = false;
                loc2 = cache.task.getCopyStudyTask();
                if (loc2 && loc2.status == ETaskStatus._ETaskStatusHadCompleted) 
                {
                    if ((loc3 = loc2.getTargetByIndex(0)) != null) 
                    {
                        AIManager.onAutoPathAIControl(loc3);
                    }
                }
            }
            return;
        }

        /* internal  */onEnterCopyGuide(): void
        {
            var loc2=null;
            var loc1=ThingUtil.entityUtil.getRandomMonster(EntityType.Boss, null, false, true, false, false) as MonsterPlayer;
            if (loc1 == null) 
            {
                loc2 = cache.scene.getNextRefreshPoint(-1);
                if (loc2 != null) 
                {
                    cache.guide.guideTargetPoint = true;
                    cache.guide.guideTargetEntity = loc2;
                    RolePlayer.instance.setTargetTilePoint(loc2.px, loc2.py);
                }
            }
            else 
            {
                cache.guide.guideTargetPoint = true;
                cache.guide.guideTargetEntity = loc1;
                RolePlayer.instance.setTargetTilePoint(loc1.currentPoint.x, loc1.currentPoint.y);
            }
            return;
        }

        /* internal  */onCopyAutoFightAlertHandler(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightKeyToFight));
            }
            return;
        }

        /* internal  */onGuideItemUsed(arg1: DataEvent): void
        {
            if (!this._breaking) 
            {
                flash.utils.clearTimeout(this._timerKey);
                this.guideTimer();
            }
            return;
        }

        /* internal  */onFirstAttackHide(arg1: DataEvent): void
        {
            if (!this._breaking) 
            {
                flash.utils.clearTimeout(this._timerKey);
                this.guideTimer();
            }
            return;
        }

        /* internal  */onShopCloseHandler(arg1: DataEvent): void
        {
            this.hideNpcEffectGuide();
            return;
        }

        /* internal  */onWareCloseHandler(arg1: DataEvent): void
        {
            if (this.hideNpcEffectGuide()) 
            {
                Dispatcher.removeEventListener(EventName.WareClose, this.onWareCloseHandler);
            }
            return;
        }

        /* internal  */onGuildListWindowClose(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            if (cache.guide.guideApplyGuild) 
            {
                cache.guide.guideApplyGuild = false;
                if (RolePlayer.instance.isRest || RolePlayer.instance.actionState == ActionType.Stand || RolePlayer.instance.actionState == ActionType.MountStand) 
                {
                    loc1 = cache.task.getTaskByType(ETaskType._ETaskTypeApplyGuild);
                    if (loc1.length > 0) 
                    {
                        loc2 = loc1[0];
                        if (loc2.status == ETaskStatus._ETaskStatusHadCompleted) 
                        {
                            if (!((loc3 = loc2.getTargetByIndex(0)) == null) && (cache.dialog.npcInfo == null || cache.dialog.npcInfo.tnpc.npcId == loc3.id)) 
                            {
                                AIManager.onAutoPathAIControl(loc3);
                            }
                        }
                    }
                }
            }
            return;
        }

        /* internal  */onEquipmentWindowCloseHandler(arg1: DataEvent): void
        {
            this.hideNpcEffectGuide();
            if (cache.guide.guideEquipRefresh) 
            {
                this.playEquipSwf();
                cache.guide.guideEquipRefresh = false;
                this.guideTimer();
            }
            return;
        }

        /* internal  */playEquipSwf(): void
        {
            if (!this._guideEquipSwf) 
            {
                this._guideEquipSwf = new SWFPlayer();
                this._guideEquipSwf.timeRate = 1;
            }
            LayerManager.topLayer.addChild(this._guideEquipSwf);
            this._guideEquipSwf.loadComplete = this.onEquipSwfLoaded;
            this._guideEquipSwf.load(StaticResUrl.GuideEquipOptSwf, ModelType.NormalSwf, null);
            return;
        }

        /* internal  */onEquipSwfLoaded(arg1: SWFPlayer): void
        {
            this._guideEquipSwf.addFrameScript((this._guideEquipSwf.totalFrames - 1), this.onGuideEquipSwfCom);
            this._guideEquipSwf.updateFrame(ActionType.Stand, 1, true);
            this._guideEquipSwf.updateCurrentFrame(0);
            this._guideEquipSwf.play();
            this._guideEquipSwf.move(Global.stage.stageWidth / 2, Global.stage.stageHeight / 2 - this._guideEquipSwf.height / 2);
            return;
        }

        /* internal  */onGuideEquipSwfCom(): void
        {
            if (this._guideEquipSwf) 
            {
                this._guideEquipSwf.stop();
                flash.utils.setTimeout(this.guideEquipDispose, 5000);
            }
            return;
        }

        /* internal  */guideEquipDispose(): void
        {
            if (this._guideEquipSwf) 
            {
                this._guideEquipSwf.dispose();
                this._guideEquipSwf = null;
            }
            return;
        }

        /* internal  */onPetForgetCloseHandler(arg1: DataEvent): void
        {
            this.hideNpcEffectGuide();
            return;
        }

        /* internal  */hideNpcEffectGuide(): Boolean
        {
            if (cache.dialog.npcInfo && cache.guide.isGuideNpcEffect(cache.dialog.npcInfo.tnpc.npcId)) 
            {
                cache.guide.guideNpcEffect = false;
                if (!this._breaking) 
                {
                    flash.utils.clearTimeout(this._timerKey);
                    this.guideTimer();
                }
                if (!GameController.pack.view.isHide) 
                {
                    GameController.pack.view.hide();
                }
                return true;
            }
            return false;
        }

        /* internal  */onPetBattleHandler(arg1: DataEvent): void
        {
            if (cache.guide.petGuide) 
            {
                cache.guide.petBattle = true;
                Dispatcher.removeEventListener(EventName.PetBattle, this.onPetBattleHandler);
            }
            return;
        }

        /* internal  */onPetBattleSuccessHandler(arg1: DataEvent): void
        {
            if (cache.guide.petGuide || cache.guide.petBattle) 
            {
                GameController.pet.view.hide();
                cache.guide.petGuide = false;
                Dispatcher.removeEventListener(EventName.PetBattleSuccess, this.onPetBattleSuccessHandler);
                this.guideTimer();
            }
            return;
        }

        /* internal  */onPetWindowCloseHandler(arg1: DataEvent): void
        {
            var loc1=null;
            if (cache.guide.petGuide) 
            {
                cache.guide.petGuide = false;
                if (!cache.guide.petBattle) 
                {
                    this.guideTimer();
                    loc1 = arg1.data as SPetInfo;
                    if (loc1 != null) 
                    {
                        cache.guide.petBattle = true;
                        Dispatcher.removeEventListener(EventName.PetBattle, this.onPetBattleHandler);
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattle, loc1));
                    }
                }
            }
            if (cache.guide.guidePetRefresh) 
            {
                cache.guide.guidePetRefreshEd = true;
                cache.guide.guidePetRefresh = false;
                this.guideTimer();
            }
            else if (cache.guide.guidePetMerge) 
            {
                cache.guide.guidePetMerge = false;
                this.guideTimer();
            }
            return;
        }

        /* internal  */onSkillWindowCloseHandler(arg1: DataEvent): void
        {
            if (cache.guide.guideSkillLearn) 
            {
                cache.guide.guideSkillLearn = false;
                Dispatcher.removeEventListener(EventName.SkillWindowClose, this.onSkillWindowCloseHandler);
                this.guideTimer();
            }
            return;
        }

        /* internal  */onPackWindowCloseHandler(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=null;
            if (cache.guide.guideUseDrug) 
            {
                if (!cache.guide.guideUseHong) 
                {
                    loc1 = cache.pack.backPackCache.getItemsByJudge(ItemsUtil.isChangeshengdan);
                    if (loc1.length > 0) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.ItemUseReq, loc1[0]));
                    }
                    cache.guide.guideUseHong = true;
                }
                if (!cache.guide.guideUseLan) 
                {
                    loc2 = cache.pack.backPackCache.getItemsByJudge(ItemsUtil.isButianwan);
                    if (loc2.length > 0) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.ItemUseReq, loc2[0]));
                    }
                    cache.guide.guideUseLan = true;
                }
                cache.guide.guideUseDrug = false;
                this.guideTimer();
            }
            else if (cache.guide.guidePetAdd) 
            {
                if (PetAddWindow.instance.isHide) 
                {
                    cache.guide.guidePetAdd = false;
                    this.guideTimer();
                }
            }
            return;
        }

        /* internal  */onPetAddWindowCloseHandler(arg1: DataEvent): void
        {
            if (cache.guide.guidePetAdd) 
            {
                cache.guide.guidePetAdd = false;
                this.guideTimer();
            }
            return;
        }

        /* internal  */onPetAddWindowShowHandler(arg1: DataEvent): void
        {
            if (cache.guide.guidePetAdd) 
            {
                if (!GameController.pack.view.isHide) 
                {
                    GameController.pack.view.hide();
                }
            }
            return;
        }

        public breakAutoPath(): void
        {
            if (cache.status.currentStatus == StatusType.AutoPath || cache.guide.isGuideWolking()) 
            {
                if (this.autoPathTimer) 
                {
                    this.autoPathTimer = false;
                    flash.utils.clearTimeout(this.autoPathTimerKey);
                }
                else if (cache.role.entityInfo.level <= 34) 
                {
                    if (AIManager.lastTarget == null || cache.guide.isGuideWolking()) 
                    {
                        this.autoPathTimer = true;
                        this.autoPathTimerKey = flash.utils.setTimeout(this.onAutoPathTimer, 1000);
                    }
                }
            }
            else 
            {
                this.autoPathTimer = false;
                flash.utils.clearTimeout(this.autoPathTimerKey);
            }
            return;
        }

        /* internal  */onAutoPathTimer(): void
        {
            this.autoPathTimer = false;
            AIManager.onAutoPathAIControl(cache.guide.dalayTarget);
            return;
        }

        /* internal  */onAIFightInDisHandler(arg1: DataEvent): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=arg1.data as MonsterPlayer;
            if (loc1 == null) 
            {
                if (cache.role.entityInfo.level <= 10) 
                {
                    if (!AutoFightRule.isAutoFight()) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightGuideBegin));
                    }
                }
            }
            else if (cache.role.entityInfo.level <= 10) 
            {
                if (!AutoFightRule.isAutoFight()) 
                {
                    if (cache.task.isTaskMonster(loc1.bossCode, ETaskGroup._ETaskGroupMain)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightGuideBegin));
                    }
                }
            }
            else if (cache.role.entityInfo.level <= 35) 
            {
                if (this._autoFightAlert == null || !this._autoFightAlert.parent) 
                {
                    if (!AutoFightRule.isAutoFight() && !(AutoFightRule.flag == AutoFightRule.AutoFightHide)) 
                    {
                        loc2 = cache.task.getTaskByMonster(loc1.bossCode, ETaskGroup._ETaskGroupMain);
                        if (!(loc2 == null) && loc2.length > 0) 
                        {
                            if (!(loc3 = loc2[0]).hasGuideAutoFight && !(loc3.sTask.guide & GuideType.AutoFight) && !GameMapUtil.isCopyMap(MapFileUtil.mapID)) 
                            {
                                if (TaskRule.isCollectByTarget(loc3.getTargetByIndex(0))) 
                                {
                                    Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightKeyToFight));
                                }
                                else 
                                {
                                    loc3.hasGuideAutoFight = true;
                                    Alert.showCloseBtn = true;
                                    Alert.okLabel = Language.getString(20321);
                                    Alert.buttonWidth = 100;
                                    this._autoFightAlert = Alert.show(Language.getString(20322), Language.getString(20055), Alert.OK, null, this.onAutoFightAlertHandler);
                                }
                            }
                        }
                    }
                }
            }
            else if (this._autoFightAlert == null || !this._autoFightAlert.parent) 
            {
                if (!AutoFightRule.isAutoFight() && !(AutoFightRule.flag == AutoFightRule.AutoFightHide)) 
                {
                    loc2 = cache.task.getTaskByMonster(loc1.bossCode);
                    if (!(loc2 == null) && loc2.length > 0) 
                    {
                        if (!(loc3 = loc2[0]).hasGuideAutoFight && !(loc3.sTask.guide & GuideType.AutoFight) && GameMapUtil.isUniqueMap(MapFileUtil.mapID)) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFightKeyToFight));
                        }
                    }
                }
            }
            return;
        }

        /* internal  */onAutoFightBeginHandler(arg1: DataEvent): void
        {
            this.hideAutoFightAlert();
            return;
        }

        /* internal  */onAutoFightEndHandler(arg1: DataEvent): void
        {
            if (cache.guide.fuBenGuide && !cache.guide.copyTaskCom) 
            {
                flash.utils.setTimeout(this.onAutoFightEndTimer, 2000);
            }
            return;
        }

        /* internal  */onAutoFightEndTimer(): void
        {
            if (cache.guide.fuBenGuide && !cache.guide.copyTaskCom) 
            {
                if (!AutoFightRule.isAutoFight()) 
                {
                    cache.guide.autoFightGuide = true;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.AutoFight));
                }
            }
            return;
        }

        /* internal  */hideAutoFightAlert(): void
        {
            if (this._autoFightAlert) 
            {
                if (this._autoFightAlert.parent) 
                {
                    this._autoFightAlert.parent.removeChild(this._autoFightAlert);
                }
                this._autoFightAlert = null;
            }
            return;
        }

        /* internal  */onPlayerFireHandler(arg1: PlayerEvent): void
        {
            if (cache.guide.guideTargetPoint && !(GameController.scene.selectEntity == null)) 
            {
                if (!cache.copy.isProcessEnd()) 
                {
                    cache.guide.guideTargetPoint = false;
                    cache.guide.guideTargetEntity = null;
                    RolePlayer.instance.removeTargetTilePoint();
                }
            }
            return;
        }

        /* internal  */onEnterFightHandler(arg1: PlayerEvent): void
        {
            if (AutoFightRule.isAutoFight() && AutoFightRule.fightAtPoint && (RolePlayer.instance.isWorking || RolePlayer.instance.isStanding)) 
            {
                if (ThingUtil.selectEntity && ThingUtil.entityUtil.isAutoFightAble(ThingUtil.selectEntity)) 
                {
                    AIManager.onAIControl(ThingUtil.selectEntity, AIType.AI_AutoFight);
                }
            }
            return;
        }

        /* internal  */onCopyProcessUpdate(arg1: Object): void
        {
            var loc1=null;
            if (cache.guide.fuBenGuide) 
            {
                if (cache.copy.isProcessEnd()) 
                {
                    loc1 = cache.scene.getNearlyPassPoint();
                    if (loc1 != null) 
                    {
                        flash.utils.setTimeout(this.copyProcessEnd, 1000, loc1);
                    }
                }
            }
            return;
        }

        /* internal  */copyProcessEnd(arg1: SPassPoint): void
        {
            cache.guide.guideTargetPoint = true;
            cache.guide.guideTargetEntity = arg1;
            RolePlayer.instance.setTargetTilePoint(arg1.point.x, arg1.point.y);
            return;
        }

        /* internal  */onGridWorkEnd(arg1: PlayerEvent): void
        {
            var loc1=null;
            if (cache.guide.guideTargetPoint && cache.guide.guideTargetEntity) 
            {
                if (typeof cache.guide.guideTargetEntity === "spasspoint") 
                {
                    RolePlayer.instance.setTargetTilePoint((cache.guide.guideTargetEntity as SPassPoint).point.x, (cache.guide.guideTargetEntity as SPassPoint).point.y);
                }
                else if (typeof cache.guide.guideTargetEntity === "monsterplayer") 
                {
                    RolePlayer.instance.setTargetTilePoint((cache.guide.guideTargetEntity as MonsterPlayer).currentPoint.x, (cache.guide.guideTargetEntity as MonsterPlayer).currentPoint.y);
                }
                else if (typeof cache.guide.guideTargetEntity === "bossrefreshinfo") 
                {
                    loc1 = ThingUtil.entityUtil.getRandomMonster(EntityType.Boss, null, false, true, false, false) as MonsterPlayer;
                    if (loc1 == null) 
                    {
                        RolePlayer.instance.setTargetTilePoint((cache.guide.guideTargetEntity as BossRefreshInfo).px, (cache.guide.guideTargetEntity as BossRefreshInfo).py);
                    }
                    else 
                    {
                        cache.guide.guideTargetEntity = loc1;
                        RolePlayer.instance.setTargetTilePoint(loc1.currentPoint.x, loc1.currentPoint.y);
                    }
                }
            }
            return;
        }

        /* internal  */onCopyResetHandler(arg1: DataEvent): void
        {
            if (cache.guide.guideTargetPoint && !(GameController.scene.selectEntity == null)) 
            {
                cache.guide.guideTargetPoint = false;
                cache.guide.guideTargetEntity = null;
                RolePlayer.instance.removeTargetTilePoint();
            }
            return;
        }

        /* internal  */onVipTestEnd(arg1: DataEvent): void
        {
            if (!cache.vip.isVIP) 
            {
                if (!this._vipTextEndWin) 
                {
                    this._vipTextEndWin = new GuideVIPBuyModule();
                }
                if (this._vipTextEndWin.isHide) 
                {
                    this._vipTextEndWin.show();
                }
            }
            return;
        }

        /* internal  */onFlyFootBuy(arg1: DataEvent): void
        {
            if (!this._flyFootBuyWin) 
            {
                this._flyFootBuyWin = new GuideBuyFlyModule();
            }
            this._flyFootBuyWin.updateData(arg1.data as TaskTargetInfo);
            if (this._flyFootBuyWin.isHide) 
            {
                this._flyFootBuyWin.show();
            }
            return;
        }

        /* internal  */onFightPointMoveEndHandler(arg1: DataEvent): void
        {
            if (!AutoFightRule.fightAtPoint) 
            {
                RolePlayer.instance.fightAtPointStart();
            }
            return;
        }

        /* internal  */onRoleLevelUpDateHandler(arg1: PlayerEvent): void
        {
            if (cache.role.entityInfo.level <= cache.guide.doubleClickLevel) 
            {
                cache.guide.doubleClick = true;
            }
            else 
            {
                cache.guide.doubleClick = false;
            }
            if (cache.role.entityInfo.level != 34) 
            {
                if (cache.role.entityInfo.level != 65) 
                {
                    if (cache.role.entityInfo.level == 70) 
                    {
                        if (cache.guide.guideDramaInfo.dramaGuide == 0) 
                        {
                            this.showDrameIcon();
                        }
                    }
                }
                else 
                {
                    cache.guide.petEquipRefresh = true;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_PetEquipRefresh));
                }
            }
            else 
            {
                RolePlayer.instance.removeEventListener(PlayerEvent.RoleLevelUpdate, this.onRoleLevelUpDateHandler);
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_ModuleOpen, ModuleType.AllShow));
            }
            return;
        }

        /* internal  */onPlayerDrameGuideRes(arg1: MessageBlock): void
        {
            cache.guide.guideDramaInfo = arg1.messageBase as SPlayerDramaGuide;
            if (cache.dialog.npcInfo) 
            {
                if (cache.guide.guideDramaInfo.dramaGuide > 0) 
                {
                    this.hideDrameIcon();
                }
            }
            else if (cache.guide.guideDramaInfo.dramaGuide > 0) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_CopyStoryGuide));
            }
            else if (cache.role.entityInfo.level >= 70) 
            {
                this.showDrameIcon();
            }
            return;
        }

        private /* var */_timerKey: uint;

        private /* var */_breaking: Boolean;

        private /* var */_alert: Object /* flash.display.Sprite */;

        private /* var */_autoEndTimer: uint;

        private /* var */_autoEndTask: TaskInfo;

        private /* var */_autoEndAlert: Object /* flash.display.Sprite */;

        private /* var */_stopFightTimeKey: uint;

        private /* var */_stopFightAlert: Object /* flash.display.Sprite */;

        private /* var */_flyFootBuyWin: IGuideBuyFlyModule;

        private /* var */_drameIcon: HintIcon;

        private /* var */autoPathTimerKey: uint;

        private /* var */_guideEquipSwf: SWFPlayer;

        private /* var */autoPathTimer: Boolean;

        private /* var */_vipTextEndWin: GuideVIPBuyModule;

        private /* var */_autoFightAlert: Object /* flash.display.Sprite */;

        private /* var */_guideFightingView: GuideFightingView;
    }
